package uk.ac.nott.cs.g53dia;
/**
 * Action which creates a nest in which to lay eggs.
 *
 * @author Neil Madden
 * @author Brian Logan
 */
/*
 * Copyright (c) 2005 Neil Madden (nem@cs.nott.ac.uk).
 * 
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */
public class CreateNestAction implements Action {

    public void execute(Environment env, Bee bee)
        throws ActionFailedException
    {
        if (!(env.getCell(bee.getPosition()) instanceof EmptyCell)) {
            throw new ActionFailedException("CreateNest: cell is not empty");
        }
        if (bee.getEnergy() < Nest.NEST_COST) {
            throw new ActionFailedException("CreateNest: not enough energy");
        }
        env.putCell(new Nest(bee.getPosition()));
        bee.useEnergy(Nest.NEST_COST);
    }

    public String toString() {
        return "Create nest";
    }
}
